/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sunsite.action;

import com.opensymphony.xwork2.ActionSupport;
import sunsite.po.News;
import sunsite.service.NewsService;
import sunsite.tools.ContextHelper;

/**
 *
 * @author mg
 */
public class ShowNews extends ActionSupport{
    public static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Messager.class);
    private NewsService newsService;
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setNewsService(NewsService newsService) {
        this.newsService = newsService;
    }

    @Override
    public String execute() throws Exception {
        News news = newsService.getNewsById(id);
        ContextHelper.getRequest().put("news", news);
        ContextHelper.getRequest().put("content", news.getContent().replaceAll("\\r\\n", "<br>"));
        return SUCCESS;
    }
}
